<template>
	<view class="viewBg">
		<view class="article-meta">
			<text class="article-author">{{title}}</text>
			<text class="article-text">发表于 : {{publishDate}}</text>
		</view>
		<view class="lineH2"></view>

		<view class="article-content">
			<rich-text :nodes="htmlString"></rich-text>
		</view>
	</view>
</template>

<script>
	export default {
		data() {
			return {
				id: '',
				title: '',
				publishDate: '',
				htmlString: ''
			}
		},
		onLoad(data) {
			if (data) {
				this.id = data.id;
				this.$http.get('ac/xagrid/appNoticeService/getNoticeDetail', {
					id: this.id,
				}).then((res) => {
					if (res.errcode === '0') {
						const obj = res.data;
						this.title = obj.title;
						this.publishDate = obj.createTime;
						this.htmlString = obj.content;
					} else {
						console.log("错误信息" + res.errmsg);
						uni.showToast({
							title: res.errmsg,
							mask: false,
							duration: 1500
						});
					}
				});
			}
		},
		onBackPress() {
			getApp().globalData.isRead = 1;
			return false;
		}
	}
</script>

<style>
	.viewBg {
		width: 100%;
		height: 100%;
	}

	.lineH2 {
		height: 32upx;
		width: 100%;
		background-color: #F7F7F7;
	}

	.article-meta {
		padding: 20upx 40upx;
		display: flex;
		flex-direction: column;
		justify-content: flex-start;
		color: gray;
	}

	.article-text {
		font-size: 26upx;
		line-height: 30upx;
		text-align: right;
		margin: 0 20upx, 20upx, 0;
	}

	.article-author,
	.article-time {
		font-size: 36upx;
		text-align: center;
		color: #000000;
	}

	.article-content {
		padding: 0 30upx;
		overflow: hidden;
		font-size: 30upx;
		margin-bottom: 30upx;
	}
</style>
